<!DOCTYPE html>
<html lang="en">

<head>

    <include file="Public/header" />
	

</head>

<body>

    <div id="wrapper">

        <include file="Public/nav" />

        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">系统设置</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>

            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                        	添加设置
                        </div>
                        
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                        	<div class="row">
                            	<form id="sys_var_form" role="form">
                            		<div class="col-lg-6">
	                            		<div class="form-group">
	                                         <label>变量</label>
	                                         <input name="sys_title" type="text" class="form-control" 
	                                         required="" data-parsley-minlength="2" data-parsley-minlength-message="变量不小于2位" 
	                                         data-parsley-maxlength="100" data-parsley-maxlength-message="变量不大于50位" 
	                                         data-parsley-required-message="变量 必填" placeholder="请输入变量">
	                                     </div>
	                                     
	                                     <div class="form-group">
	                                         <label>值</label>
	                                         <input name="sys_content" type="text" class="form-control" 
	                                         data-parsley-minlength="1" data-parsley-minlength-message="值不小于1位"
	                                         data-parsley-maxlength="100" data-parsley-maxlength-message="值不大于100位" 
	                                         data-parsley-required-message="值 必填" placeholder="请输入值">
	                                     </div>
	                                     
	                                     <div class="form-group">
	                                         <label>描述</label>
	                                         <input name="sys_var" type="text" class="form-control" 
	                                       
	                                         data-parsley-maxlength="200" data-parsley-maxlength-message="描述不大于100位" 
	                                         data-parsley-required-message="描述 必填" placeholder="请输入描述">
	                                     </div>
	                                     
	                                     <div class="form-group">
	                                     	<button type="submit" class="btn btn-primary">提 交</button>
	                                     	<button type="reset" class="btn btn-default">重 置</button>
	                                     	<a href="javascript:history.back(-1)" type="button" class="btn btn-default">返 回</a>
	                                     </div>
	                                     
                                     </div>
                            	</form>
                        	</div>

                            <!-- /.table-responsive -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-6 -->
                <!-- /.col-lg-6 -->
            </div>
            
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <include file="Public/footer" />
	<script type="text/javascript" src="__RAC__/js/parsleyjs/parsley.min.js"></script>
	
	<script type="text/javascript">
	$(function () {
		$('#sys_var_form').parsley().on('form:submit', function() {
        	var obj = $('#sys_var_form').serialize();
        	var layer_index = null;
           	$.ajax({
           	    type: "POST",
           	    url: "{:U('Sys/add_form')}",
           	    data: obj,// 要提交的表单
           	    dataType: 'json',
           	    beforeSend: function(){
   					layer_index = layer.load(1, {
   					  	shade: [0.1, '#ccc'] //0.1透明度的白色背景
   					});
   				},
           	    success: function (data, response) {
           	    	layer.close(layer_index);
           	    	if (data.flag > 0) {
           	    		location.href = "{:U('Sys/set_var')}";
           	    		layer.msg(data.msg);
           	    	} else {
           	    		layer.msg(data.msg);
           	    	}
           	    },
           	    error: function (error) {
           	    	layer.close(layer_index);
           	    	layer.msg('error');
           	    }
           	  });
        	  
        	 return false;
        });
		
	});
	
	</script>
</body>

</html>
